const fs = require('fs');

// 创建可读流
const readStream = fs.createReadStream('from.txt');
// 创建可写流
const writeStream = fs.createWriteStream('to.txt');

// 管道转换
readStream.on('data', (chunk) => {
    // 将数据转换为大写
    const upperChunk = chunk.toString().toUpperCase();
    // 写入转换后的数据
    writeStream.write(upperChunk);
});

readStream.on('end', () => {
    writeStream.end();
    console.log('转换完成');
});